package com.ruoyi.business.domain.enums;

public enum UserTypeEnum {
    STUDENT("0", "学生"),
    PARENT("1", "家长"),
    TEACHER("2", "教师");

    private final String key;
    private final String label;

    UserTypeEnum(String key, String label) {
        this.key = key;
        this.label = label;
    }

    public String getKey() {
        return key;
    }

    public String getLabel() {
        return label;
    }

    // 根据键值获取枚举实例
    public static UserTypeEnum fromKey(String key) {
        for (UserTypeEnum role : UserTypeEnum.values()) {
            if (role.getKey().equals(key)) {
                return role;
            }
        }
        throw new IllegalArgumentException("No enum constant for [" + key + "]");
    }
}